package com.example.mydemo103.Adapter;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.List;

public class MyPagerAdapter extends FragmentPagerAdapter {
    private List<Fragment> fragments;
//    传入数据初始化构造
    public MyPagerAdapter(@NonNull FragmentManager fm, List<Fragment> behavior) {
        super(fm);
        this.fragments=behavior;
    }
//    获取fragment长度
    @Override
    public int getCount() {
        return fragments.size();
    }
//    初始化数据
    @NonNull
    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

}
